// PostgreSQL 常用关键字
const pgKeywords = [
    // 基础 DML
    'SELECT', 'FROM', 'WHERE', 'GROUP BY', 'ORDER BY', 'HAVING', 'LIMIT', 'OFFSET',
    'INSERT', 'INTO', 'VALUES', 'UPDATE', 'SET', 'DELETE',

    // DDL
    'CREATE', 'ALTER', 'DROP', 'TABLE', 'VIEW', 'INDEX', 'SEQUENCE', 'TRIGGER', 'FUNCTION', 'PROCEDURE',
    'SCHEMA', 'DATABASE', 'EXTENSION', 'TYPE',

    // 连接
    'JOIN', 'INNER JOIN', 'LEFT JOIN', 'RIGHT JOIN', 'FULL JOIN', 'CROSS JOIN', 'NATURAL JOIN', 'ON', 'USING',

    // 条件
    'AND', 'OR', 'NOT', 'IN', 'BETWEEN', 'LIKE', 'ILIKE', 'IS NULL', 'IS NOT NULL', 'EXISTS', 'DISTINCT',

    // 事务
    'BEGIN', 'COMMIT', 'ROLLBACK', 'SAVEPOINT', 'RELEASE SAVEPOINT', 'TRUNCATE',

    // 其他
    'AS', 'CASE', 'WHEN', 'THEN', 'ELSE', 'END', 'WITH', 'RECURSIVE', 'UNION', 'INTERSECT', 'EXCEPT',
    'DEFAULT', 'RETURNING', 'CAST', 'NULL', 'TRUE', 'FALSE'
];

// PostgreSQL 常用聚合函数
const pgAggregateFunctions = [
    'COUNT', 'SUM', 'AVG', 'MIN', 'MAX', 'ARRAY_AGG', 'STRING_AGG'
];

// PostgreSQL 常用字符串函数
const pgStringFunctions = [
    'CONCAT', 'CONCAT_WS', 'SUBSTRING', 'UPPER', 'LOWER', 'TRIM', 'LTRIM', 'RTRIM',
    'REPLACE', 'SPLIT_PART', 'LEFT', 'RIGHT', 'LPAD', 'RPAD', 'FORMAT'
];

// PostgreSQL 常用日期时间函数
const pgDateFunctions = [
    'NOW', 'CURRENT_DATE', 'CURRENT_TIME', 'CURRENT_TIMESTAMP',
    'AGE', 'DATE_PART', 'DATE_TRUNC', 'EXTRACT', 'TO_CHAR', 'TO_DATE'
];

// PostgreSQL 数学函数
const pgMathFunctions = [
    'ABS', 'CEIL', 'CEILING', 'FLOOR', 'ROUND', 'RANDOM', 'POWER', 'MOD', 'GREATEST', 'LEAST'
];

// PostgreSQL JSON/JSONB 常用函数
const pgJsonFunctions = [
    'TO_JSON', 'TO_JSONB', 'ROW_TO_JSON', 'JSON_AGG', 'JSONB_AGG',
    'JSON_BUILD_OBJECT', 'JSONB_BUILD_OBJECT', 'JSON_BUILD_ARRAY', 'JSONB_BUILD_ARRAY',
    'JSON_EXTRACT_PATH_TEXT', 'JSONB_EXTRACT_PATH_TEXT'
];

// select下常用子标签
export const selectChildTags = [
    "if",
    "where",
    "foreach",
    "choose",
    "when",
    "otherwise",
    "set",
    "trim",
    "bind",
];

// 给每个子标签定义常用属性
export const attributesByTag = {
    if: ["test"],
    where: [],
    foreach: ["collection", "item", "index", "open", "close", "separator"],
    choose: [],
    when: ["test"],
    otherwise: [],
    set: [],
    trim: ["prefix", "suffix", "prefixOverrides", "suffixOverrides"],
    bind: ["name", "value"],
};

export const sqlKeywords = [
    ...pgKeywords,
    ...pgAggregateFunctions,
    ...pgStringFunctions,
    ...pgDateFunctions,
    ...pgMathFunctions,
    ...pgJsonFunctions
];

